package com.pikaqiu.warehouse.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pikaqiu.warehouse.domain.entity.UserCompany;
import com.pikaqiu.warehouse.mapper.UserCompanyMapper;
import com.pikaqiu.warehouse.service.UserCompanyService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author Administrator
* @description 针对表【user_company(用户-公司关联表)】的数据库操作Service实现
* @createDate 2024-08-14 18:58:12
*/
@Service
public class UserCompanyServiceImpl extends ServiceImpl<UserCompanyMapper, UserCompany>
    implements UserCompanyService{

    @Override
    public List<UserCompany> listUserCompanyId(Integer userId) {
        List<UserCompany> list = list(new QueryWrapper<UserCompany>().eq("user_id", userId)
            .eq("status", 0));
        if (CollectionUtil.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list;
    }

    @Override
    public List<UserCompany> listByCompanyId(Integer companyId) {
        List<UserCompany> list = list(new QueryWrapper<UserCompany>().eq("company_id", companyId)
            .eq("status", 0));
        if (CollectionUtil.isEmpty(list)) {
            return Collections.emptyList();
        }
        return list;
    }
}




